#define _CRT_SECURE_NO_WARNINGS 1
/**
*      author: Y_Yao
*      created: 2024-10-21 21:37:03
**/

#include<bits/stdc++.h>

using namespace std;
#define int LL
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 2e5 + 7;
int w[N], v[N], l[N], r[N], pn[N], pv[N];
int n, m, s, y;

bool check(int mid)
{
    y = 0;
    memset(pv, 0, sizeof pv);
    memset(pn, 0, sizeof pn);
    for (int i = 1;i <= n;i++)
    {
        if (w[i] >= mid)
        {
            pn[i] = pn[i - 1] + 1;
            pv[i] = pv[i - 1] + v[i];
        }
        else
        {
            pn[i] = pn[i - 1];
            pv[i] = pv[i - 1];
        }
    }

    for (int i = 1;i <= m;i++)
    {
        y += (pn[r[i]] - pn[l[i] - 1]) * (pv[r[i]] - pv[l[i] - 1]);
    }

    if (s >= y) return true;
    else return false;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int maxw = -INF;
    cin >> n >> m >> s;
    for (int i = 1;i <= n;i++)
    {
        cin >> w[i] >> v[i];
        maxw = max(maxw, w[i]);
    }

    for (int i = 1;i <= m;i++)
    {
        cin >> l[i] >> r[i];
    }

    int l = 0, r = maxw + 1;
    int ans = 1e18;
    while (l <= r)
    {
        int mid = (l + r) >> 1;
        if (check(mid)) r = mid - 1;
        else l = mid + 1;
        ans = min(ans, llabs(y - s));
    }
    cout << ans << endl;
    return 0;
}